<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\Staff
 *
 * @property int $id
 * @property int $user_id 用户id
 * @property string|null $realname 姓名
 * @property string|null $phone 手机
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\Staff onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff wherePhone($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereRealname($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereUserId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Staff withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Staff withoutTrashed()
 * @mixin \Eloquent
 * @property int $person_img_id 个人形象图片
 * @property string|null $introduce 个人简介
 * @property string|null $address 个人地址
 * @property string|null $email 个人邮箱
 * @property string|null $position 个人职位
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereAddress($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereEmail($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereIntroduce($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff wherePersonImgId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff wherePosition($value)
 * @property string|null $address_detail 个人地址
 * @property string|null $address_area 个人地址
 * @property string|null $address_city 个人地址
 * @property string|null $address_province 个人地址
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereAddressArea($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereAddressCity($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereAddressDetail($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereAddressProvince($value)
 * @property int $share_img_id 用户分享图片的id
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereShareImgId($value)
 * @property int $qrcode_img_id 用户二维码
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereQrcodeImgId($value)
 * @property string|null $staff_key 标识
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Staff whereStaffKey($value)
 */
class Staff extends Model
{
    protected $table = "staff";
    use SoftDeletes;
    public static function getStaffInfo($id){
        return self::whereId($id)->first() ?? [];
    }

    /**
     * @param $user_id
     * @return int|mixed
     */
    public static function getUserStaffId($user_id){
        if (!$user_id)
            return 0;
        $data = Staff::whereUserId($user_id)->first();
        if (!$data)
            return 0;
        return $data->id;
    }
}
